﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace WGM_Client_Silverlight
{
    public class HelperFunctions
    {
        public static Color GetNewColour(WGM_Service.UserOptions uo)
        {
            return Color.FromArgb(255,(byte)uo.FontColourR, (byte)uo.FontColourG, (byte)uo.FontColourB);
        }

        public static FontStyle GetFontStyle(int oldStyle)
        {
            switch (oldStyle)
            {
                case 0:
                    return FontStyles.Normal;
                default:
                    return FontStyles.Normal;
            }
        }
        public static string GetIntroString(WGM_Service.UserOptions clientData)
        {

            string retVal = clientData.DisplayName;
            if (clientData.DisplayName.Trim() == "")
                retVal = clientData.UserName;

            return retVal;
        }
        public static string GetIntroString(WGM_Service.UserOptions clientData, int maxLength)
        {

            string retVal = clientData.DisplayName;
            if (clientData.DisplayName.Trim() == "")
                retVal = clientData.UserName;

            if (retVal.Length > maxLength)
            {
                retVal = retVal.Substring(0, maxLength - 3);
                retVal += "...";
            }
            return retVal;
        }
        public static SolidColorBrush GetBrushColour(WGM_Service.UserOptions uo)
        {
            return new SolidColorBrush(Color.FromArgb(255, (byte)uo.FontColourR, (byte)uo.FontColourG, (byte)uo.FontColourB));
        }
        public static Color GetColour(WGM_Service.UserOptions uo)
        {
            return Color.FromArgb(255, (byte)uo.FontColourR, (byte)uo.FontColourG, (byte)uo.FontColourB);
        }
        public static string GetContactTitle(WGM_Service.UserOptions clientData)
        {
            string retVal = clientData.DisplayName;
            if (clientData.DisplayName.Trim() == "")
                retVal = clientData.UserName;
            if (clientData.UserStatus != null && clientData.UserStatus.Trim() != "")
                retVal += " - " + clientData.UserStatus;

            return retVal;
        }

        public static string GetCLToolTip(WGM_Service.UserOptions clientData)
        {
            string retVal = clientData.DisplayName;
            if (clientData.UserStatus != null && clientData.UserStatus.Trim() != "")
                retVal += " - " + clientData.UserStatus;

            retVal += " (" + clientData.UserName + ")";

            return retVal;
        }
        public static bool IsMessageValid(WGM_Service.WGMMessage message, DateTime logonTime, TimeSpan serverTimeOffset)
        {
            if (message.TimeStamp < logonTime)
                return false;


            return true;
        }

    }
}
